﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using PartyInvites.Models.Product;
using PartyInvites.Models.Product.Extension;

namespace PartyInvites.Controllers
{
    public class ShopCartController : Controller
    {
        // GET: ShopCart
        public ActionResult Index()
        {
            //ProductObj[] products = 
            //{
            //    new ProductObj {Price = 1},
            //    new ProductObj {Price = 2},
            //    new ProductObj {Price = 3}
            //};
            //var cart = new ShoppingCart { Products = products.ToList()};

            //var total = cart.GetTotal();
            //var total2 = products.GetTotal();
            //var total3 = products.GetTotalByType("Oranger");


            //bool CategoryFilter(ProductObj prod)
            //{
            //    return prod.Type == "Orange" && prod.Price > 0;
            //}

            //var total4 = products.GetTotalByFilter(CategoryFilter);

            //bool CategoryFilter2(ProductObj prod)
            //{
            //    return prod.Type == "Orange" && prod.Price > 0;
            //}

            //var total5 = products.GetTotalByFilter(CategoryFilter2);

            //Func<ProductObj, bool> categoryFilter = prod => prod.Type == "Oranger";
            //var productObjs = products.Filter(categoryFilter);


            ////定义数组
            //ProductObj[] objs = new ProductObj[3];
            ////排序
            //Array.Sort(products, (item1, item2) => Comparer<decimal>.Default.Compare(item1.Price, item2.Price));

            //var tempList = objs.Filter(o => o.Type == "Apple");
            ////获取数组前三项为结果
            //Array.Copy(products,objs,3);

            return View();
        }
    }
}